pub fn convert_base(num_str: &str, target_base: u32) -> String {
    // 预处理: 解析输入的数字和其原始进制
    let parts: Vec<&str> = num_str.trim_end_matches(')').split('(').collect();
    let num = parts[0];
    let source_base = parts[1].parse::<u32>().unwrap();
    
    // 1. 先转为10进制
    let decimal = match source_base {
        10 => num.parse::<i32>().unwrap(),
        _ => i32::from_str_radix(num, source_base).unwrap()
    };
    
    // 2. 从10进制转为目标进制
    match target_base {
        2..=16 => {
            let mut result = String::new();
            let mut n = decimal;
            while n > 0 {
                let digit = n % (target_base as i32);
                let char = match digit {
                    0..=9 => (digit + '0' as i32) as u8 as char,
                    10..=15 => ((digit - 10 + 'a' as i32) as u8) as char,
                    _ => unreachable!()
                };
                result.insert(0, char);
                n /= target_base as i32;
            }
            if result.is_empty() {
                "0".to_string()
            } else {
                // format!("{}({})", result, target_base)
                format!("{}", result)
            }
        },
        _ => panic!("Unsupported base")
    }
}
